import http from '@/axios/http'
import axios from 'axios'
import store from '@/store'

const apiFun = {}

apiFun.getList = function (params) {
  return http.get('', params)
}

apiFun.ver = function () {
  return http.get('/user/ver')
}
apiFun.ver2 = function () {
  return http.get('/user/ver2')
}
apiFun.sign = function (params) {
  return http.get('/user/sign', params)
}
apiFun.sendCode = function (params) {
  return http.get('/user/sendCode', params)
}
apiFun.login = function (params) {
  return http.get('/user/login', params)
}
apiFun.getMessageList = function (params) {
  return http.get('/message/getMessageList', params)
}
apiFun.getRecommendMessage = function () {
  return http.get('/message/getRecommendMessage')
}
apiFun.getRandomWord = function () {
  return http.get('/word/getRandomWord')
}

apiFun.searchEssayList = function (params) {
  return http.get('/message/searchEssayList', params)
}
apiFun.getWordsList = function (params) {
  return http.get('/word/getList', params)
}
apiFun.searchWord = function (params) {
  return http.get('/word/searchWord', params)
}
apiFun.getPlan = function (params) {
  return http.get('/plan/getPlan', params)
}
apiFun.getRootData = function (params) {
  return http.get('/pr/getRootData', params)
}
apiFun.addPlan = function (params) {
  return http.get('/plan/addPlan', params)
}
apiFun.getPracticeWords = function (params) {
  return http.get('/practice/getPracticeWords', params)
}
apiFun.updateFinish = function (params){
  return http.get('/practice/updateFinish',params)
}

apiFun.getWeather = function () {
  return new Promise(resolve => {
    axios.get('https://v0.yiketianqi.com/free/day?appid=58571393&appsecret=LW1lcfJF&version=v61').then(res => {
      resolve(res)
      // console.log(res)
      return res
    })
  })
}

apiFun.translate = function (params) {
  return new Promise((resolve, reject) => {
    axios.get(store.getters.getBaiduTan.tranAPI, {
      params: params
    }).then(res => {
      resolve(res)
    })
  })
}

export default apiFun
